<?php
/**
 *
 * 版权所有：恰维网络<qwadmin.qiawei.com>
 * 作    者：寒川<hanchuan@qiawei.com>
 * 日    期：2016-01-20
 * 版    本：1.0.0
 * 功能说明：用户控制器。
 *
 **/

namespace Qwadmin\Controller;

class GuController extends ComController
{

	public function add()
	{
		if (IS_POST) {
			$dada = M('member')->where(array('uid'=>$_SESSION['uid']))->select();
	        $z_id = M('auth_group_access')->where(array('uid'=>$_SESSION['uid']))->select();
	                
	        $b_id = $z_id[0]['group_id'];
	        $m_list = M('auth_group')->where(array('id'=>$b_id))->select();
	        $slist = M('stock')->where(['id'=>$_POST['id']])->select();
	        $list = $_POST;
	      foreach ($list as $k => $v ){
           foreach ($v as $key => $value){
               if (!$value){
                   unset($list[$k][$key]);
                   continue;
               }
           }
           // if(empty($v)){
           //     unset($list[$k]);
           // }
          }
          $result = array_filter($list);
	        // dump($list);
	        // exit;
        
          switch ($dada[0]['m_type']) {
                  case '2':  //主管
                        // dump($_POST);
                        // exit;
                        if ($m_list[0]['post'] == '行政中心') {
                            
                           foreach ($result as  $value) {
                                        $value['time'] = date('Y-m-d');
                                        $value['ment'] = $m_list[0]['post'];
                                        $value['type'] = 2;
                                        $value['uname'] = $dada[0]['user'];
                                        $value['look'] = 8;
                                        $r[] = $value;              
                                        // $r[] = $aa;                       
                                      }
                                      $count = count($r);
                                    if (M('look')->addALL($r) > 0) {
                                        $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                       foreach ($llist as  $v) {
                                          // dump($v);
                                          $date['zname'] = $dada[0]['user'];
                                          $date['ztype'] = $dada[0]['m_type'];
                                          $date['stype'] = 1;
                                          $date['ztime'] = date('Y-m-d');
                                          $date['sid'] = $v['id'];
                                          $date['wtype'] = '固定资产';
                                          // dump($date);
                                          $d[] = $date;
                                        }
                                        
                                        // exit;
                                       if (M('sh')->addALL($d) > 0) {
                                             $this->success('添加成功');
                                        } 

                                    }else{
                                       $this->error('添加失败');
                                    }



                        }else{
                            if ($m_list[0]['post'] == '采购中心') {

                                
                               foreach ($result as  $value) {
                                        $value['time'] = date('Y-m-d');
                                        $value['ment'] = $m_list[0]['post'];
                                        $value['type'] = 2;
                                        $value['uname'] = $dada[0]['user'];
                                        $value['look'] = 9;
                                        $r[] = $value;                               
                                      }
                                      $count = count($r);
                                    if (M('look')->addALL($r) > 0) {
                                        $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                        foreach ($llist as  $v) {
                                          // dump($v);
                                          $date['zname'] = $dada[0]['user'];
                                          $date['ztype'] = $dada[0]['m_type'];
                                          $date['stype'] = 1;
                                          $date['ztime'] = date('Y-m-d');
                                          $date['sid'] = $v['id'];
                                          $date['wtype'] = '固定资产';
                                          // dump($date);
                                          $d[] = $date;
                                        }
                                        
                                        // exit;
                                       if (M('sh')->addALL($d) > 0) {
                                             $this->success('添加成功');
                                        } 

                                    }else{
                                       $this->error('添加失败');
                                    }


                              
                            }else{
                                if ($m_list[0]['post'] == '财务中心') {
                                    
                                    foreach ($result as  $value) {
                                        $value['time'] = date('Y-m-d');
                                        $value['ment'] = $m_list[0]['post'];
                                        $value['type'] = 2;
                                        $value['uname'] = $dada[0]['user'];
                                        $value['look'] = 10;
                                        $r[] = $value;                                     
                                      }
                                      $count = count($r);
                                    if (M('look')->addALL($r) > 0) {
                                        $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                        foreach ($llist as  $v) {
                                          // dump($v);
                                          $date['zname'] = $dada[0]['user'];
                                          $date['ztype'] = $dada[0]['m_type'];
                                          $date['stype'] = 1;
                                          $date['ztime'] = date('Y-m-d');
                                          $date['sid'] = $v['id'];
                                          $date['wtype'] = '固定资产';
                                          // dump($date);
                                          $d[] = $date;
                                        }
                                        
                                        // exit;
                                       if (M('sh')->addALL($d) > 0) {
                                             $this->success('添加成功');
                                        } 

                                    }else{
                                       $this->error('添加失败');
                                    }
                                }else{
                                  // echo '12';
                                  // exit;
                                    
                                      foreach ($result as  $value) {
                                        $value['time'] = date('Y-m-d');
                                        $value['ment'] = $m_list[0]['post'];
                                        $value['type'] = 2;
                                        $value['uname'] = $dada[0]['user'];
                                        $value['look'] = 1;
                                        $r[] = $value;                                     
                                      }
                                      $count = count($r);
                                    if (M('look')->addALL($r) > 0) {
                                        $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                                        // dump($llist);
                                        // exit;
                                        foreach ($llist as  $v) {
                                          // dump($v);
                                          $date['zname'] = $dada[0]['user'];
                                          $date['ztype'] = $dada[0]['m_type'];
                                          $date['stype'] = 1;
                                          $date['ztime'] = date('Y-m-d');
                                          $date['sid'] = $v['id'];
                                          $date['wtype'] = '固定资产';
                                          // dump($date);
                                          $d[] = $date;
                                        }
                                        
                                        // exit;
                                       if (M('sh')->addALL($d) > 0) {
                                             $this->success('添加成功');
                                        } 

                                    }else{
                                       $this->error('添加失败');
                                    }
                                }
                            }
                        }
                    break;
                  case '3':  //经理
                      // echo '111';
                      // exit;
                      foreach ($result as  $value) {
                        $value['time'] = date('Y-m-d');
                        $value['ment'] = $m_list[0]['post'];
                        $value['type'] = 2;
                        $value['uname'] = $dada[0]['user'];
                        $value['look'] = 2;
                        $r[] = $value;                                     
                      }
                      // dump($r);
                      // exit;
                      $count = count($r);
                      if (M('look')->addALL($r) > 0) {
                          $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                          foreach ($llist as  $v) {
                            // dump($v);
                            $date['jname'] = $dada[0]['user'];
                            $date['jtype'] = $dada[0]['m_type'];
                            $date['stype'] = 1;
                            $date['jtime'] = date('Y-m-d');
                            $date['sid'] = $v['id'];
                            $date['wtype'] = '固定资产';
                            // dump($date);
                            $d[] = $date;
                          }
                                        
                          // exit;
                          if (M('sh')->addALL($d) > 0) {
                                $this->success('添加成功');
                          } 

                      }else{
                          $this->error('添加失败');
                      }
                     
                    break;
                  case '4':  //行政
                      
                       foreach ($result as  $value) {
                        $value['time'] = date('Y-m-d');
                        $value['ment'] = $m_list[0]['post'];
                        $value['type'] = 2;
                        $value['uname'] = $dada[0]['user'];
                        $value['look'] = 8;
                        $r[] = $value;                       
                      }
                      $count = count($r);
                      if (M('look')->addALL($r) > 0) {
                          $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                          foreach ($llist as  $v) {
                            // dump($v);
                            $date['zname'] = $dada[0]['user'];
                            $date['ztype'] = $dada[0]['m_type'];
                            $date['stype'] = 1;
                            $date['ztime'] = date('Y-m-d');
                            $date['sid'] = $v['id'];
                            $date['wtype'] = '固定资产';
                            // dump($date);
                            $d[] = $date;
                          }
                                        
                          // exit;
                          if (M('sh')->addALL($d) > 0) {
                                $this->success('添加成功');
                          } 

                      }else{
                          $this->error('添加失败');
                      }
                    break;
                  case '5':   //财务
                       
                        foreach ($result as  $value) {
                        $value['time'] = date('Y-m-d');
                        $value['ment'] = $m_list[0]['post'];
                        $value['type'] = 2;
                        $value['uname'] = $dada[0]['user'];
                        $value['look'] = 10;
                        $r[] = $value;                       
                      }
                      $count = count($r);
                      if (M('look')->addALL($r) > 0) {
                          $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                          foreach ($llist as  $v) {
                            // dump($v);
                            $date['zname'] = $dada[0]['user'];
                            $date['ztype'] = $dada[0]['m_type'];
                            $date['stype'] = 1;
                            $date['ztime'] = date('Y-m-d');
                            $date['sid'] = $v['id'];
                            $date['wtype'] = '固定资产';
                            // dump($date);
                            $d[] = $date;
                          }
                                        
                          // exit;
                          if (M('sh')->addALL($d) > 0) {
                                $this->success('添加成功');
                          } 

                      }else{
                          $this->error('添加失败');
                      }
                    break;
                  case '8':   //职能总
                      
                      foreach ($result as  $value) {
                        $value['time'] = date('Y-m-d');
                        $value['ment'] = $m_list[0]['post'];
                        $value['type'] = 2;
                        $value['uname'] = $dada[0]['user'];
                        $value['look'] = 2;
                        $r[] = $value;                      
                      }
                      $count = count($r);
                      if (M('look')->addALL($r) > 0) {
                          $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                          foreach ($llist as  $v) {
                            // dump($v);
                            $date['jname'] = $dada[0]['user'];
                            $date['jtype'] = $dada[0]['m_type'];
                            $date['stype'] = 1;
                            $date['jtime'] = date('Y-m-d');
                            $date['sid'] = $v['id'];
                            $date['wtype'] = '固定资产';
                            // dump($date);
                            $d[] = $date;
                          }
                                        
                          // exit;
                          if (M('sh')->addALL($d) > 0) {
                                $this->success('添加成功');
                          } 

                      }else{
                          $this->error('添加失败');
                      }
                    break;
                  case '9':   //网络总
                      
                      foreach ($result as  $value) {
                        $value['time'] = date('Y-m-d');
                        $value['ment'] = $m_list[0]['post'];
                        $value['type'] = 2;
                        $value['uname'] = $dada[0]['user'];
                        $value['look'] = 2;
                        $r[] = $value;                       
                      }
                      $count = count($r);
                      if (M('look')->addALL($r) > 0) {
                          $llist = M('look')->where(['uname'=>$dada[0]['user']])->order('id desc')->limit($count)->select();
                          foreach ($llist as  $v) {
                            // dump($v);
                            $date['jname'] = $dada[0]['user'];
                            $date['jtype'] = $dada[0]['m_type'];
                            $date['stype'] = 1;
                            $date['jtime'] = date('Y-m-d');
                            $date['sid'] = $v['id'];
                            $date['wtype'] = '固定资产';
                            // dump($date);
                            $d[] = $date;
                          }
                                        
                          // exit;
                          if (M('sh')->addALL($d) > 0) {
                                $this->success('添加成功');
                          } 

                      }else{
                          $this->error('添加失败');
                      }
                    break;
                case '0':
                      foreach ($result as  $value) {
                        $value['time'] = date('Y-m-d');
                        $value['ment'] = $m_list[0]['post'];
                        $value['type'] = 2;
                        $value['uname'] = $dada[0]['user'];
                        $value['look'] = 0;
                        $r[] = $value;                       
                      }
                      // dump($list);
                      // exit;
                     if (M('look')->addALL($r) > 0) {
                          $this->success('添加成功');
                      }else{
                          $this->error('添加失败');
                      }
                    break;
            }
		}else{
			$this->display();
		}
		
	}





	public function gu()
	{	$db = M("gu");
		$count = $db->count();
		$pagecount = 20;
		$page = new \Think\Page($count , $pagecount);
		// $row[] = '';
		$page->parameter = $row; //此处的row是数组，为了传递查询条件
		$page->setConfig('first');
		$page->setConfig('prev','上一页');
		$page->setConfig('next','下一页');
		$page->setConfig('last','尾页');
		$page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
		$show = $page->show();
		$list = $db->order('class desc')->limit($page->firstRow.','.$page->listRows)->select();
			// $list = M('gu')->order('id desc')->select();
		$this->assign('list',$list);
		$this->assign('page',$show);
		$this->display();
		
	}










	public function eadd()
	{
			// dump($_FILES ['file_stu'] ['name']);
			// exit;

		$model=M("gu");
		if (! empty ( $_FILES ['file'] ['name']))
		{
			$tmp_file = $_FILES ['file'] ['tmp_name'];
			// echo $tmp_file;
			// exit;
			$file_types = explode (".",$_FILES ['file'] ['name'] );
			$file_type = $file_types[count( $file_types)-1];
			// if (strtolower( $file_type ) !== "xls" && strtolower( $file_type ) !== "xlsx" && strtolower( $file_type ) !== "csv"){
			// 	echo "<script>alert('不是Excel文件，重新上传');window.location.href='".__APP__."/StorageOut/list'</script>";
				
			// }
			$savePath = './Public/upfile/Excel';

			$str = date ( 'Ymdhis' );
			$file_name = $str . "." . $file_type;
			if (! copy ($tmp_file, $savePath.$file_name)){
				echo("failed");
			}else{
				$excelpath=$savePath . $file_name;
				$tableCols = array(
					'bhao','class','wname','gui', 'com','unit','ment','place','uname','dname','state','content'
				);
				$data=importExcel($excelpath);
				// dump($data);
				// exit;
				foreach ($data as $va) {
					// dump($va);
				
					$list['bhao'] = $va[0];
					$list['class'] = $va[1];
					$list['wname'] = $va[2];
					$list['gui'] = $va[3];
					$list['com'] = $va[4];
					$list['unit'] = $va[5];
					$list['ment'] = $va[6];
					$list['place'] = $va[7];
					$list['uname'] = $va[8];
					$list['dname'] = $va[9];
					$list['state'] = $va[10];
					$list['content'] = $va[11];
					
					$arr[] = $list;
				}
				// dump($arr);
				// exit;
					if (M('gu')->addALL($arr) > 0 ) {
						echo "<script>alert('导入成功');window.location.href='".__APP__."/Gu/gu'</script>";
					}else{
						echo "<script>alert('导入失败');window.location.href='".__APP__."/Gu/gu'</script>";
					}
					
			
				
			}
		}else{
			echo "<script>alert('请上传文件');window.location.href='".__APP__."/Gu/gu'</script>";
			
		}
	}







    //固定资产搜索
    public function sou()
    {
          // dump(I());
          $list = $_POST;
          $wname = $list['dname'];
          
    
          // $data['name']= array('like','%'.$wname.'%');
          $cname['dname']= array('like','%'.$wname.'%');
          // $data['x_type'] = $list['x_type'];
          if (empty($wname)) {
            echo '1111';
            exit;
          }
          $wlist = M('gu')->where($cname)->select();
          // dump($wlist);
          // exit;
          if (!empty($wlist)) {
             // $arr = M('stock')->where($data)->select();
              $this->ajaxReturn($wlist);
          }else{
            echo '2222';
          }

    }


   //办公用品领用返回操作
    public function fan()
    {
      // dump(I());
     
      
          $list = M('gu')->order('class desc')->select();
            if (!empty($list)) {
              $this->ajaxReturn($list);
            }else{
              echo '1111';
            }
       
    }









    public function gus()
    {
          // dump($_GET);
        // $type = $_GET['type'];
        $gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
        // dump($gid);
        // exit;
        $glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
        // dump($glist);
        // exit;
        $ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
        $apost = $glist[0]['post'];
         
      // if ($glist[0]['title'] == '超级管理员') {
      //         $db = M("look");
      //             // $where = "a_id=".$uid;
      //             $count = $db->where(['type'=>3])->count();
      //             $pagecount = 10;
      //             $page = new \Think\Page($count , $pagecount);
      //             // $row[] = '';
      //             $page->parameter = $row; //此处的row是数组，为了传递查询条件
      //             $page->setConfig('first');
      //             $page->setConfig('prev','上一页');
      //             $page->setConfig('next','下一页');
      //             $page->setConfig('last','尾页');
      //             $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
      //             $show = $page->show();
      //             $list = $db->where(['type'=>3])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
      //             $title = '部门月度申请审批';
      //             $this->assign('list',$list);
      //             $this->assign('page',$show);
      //             $this->assign('title',$title);
      //         $this->display();
      //   exit;
      // }

        switch ($ulist[0]['m_type']) {
          case '2':   //主管
              $db = M("look");
              // echo '111';
              // exit;
                  // $where = "a_id=".$uid;
                  $count = $db->where(['type'=>2,'look'=>0,'ment'=>$apost,'ju'=>0])->count();
                  // dump($apost);
                  // exit;
                  $pagecount = 10;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->where(['type'=>2,'look'=>0,'ment'=>$apost,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
                  $title = '部门固定资产审批';
                  $this->assign('list',$list);
                  $this->assign('page',$show);
                  $this->assign('title',$title);
              $this->display();
            break;



          case '3':   //经理


              switch ($apost) {
                case '行政中心':
                    $db = M("look");
                    // echo '111';
                    // exit;
                        // $where = "a_id=".$uid;
                        $count = $db->where(['look'=>8,'type'=>2,'ment'=>$apost,'ju'=>0])->count();
                        // dump($count);
                        // exit;
                        $pagecount = 9;
                        $page = new \Think\Page($count , $pagecount);
                        // $row[] = '';
                        $page->parameter = $row; //此处的row是数组，为了传递查询条件
                        $page->setConfig('first');
                        $page->setConfig('prev','上一页');
                        $page->setConfig('next','下一页');
                        $page->setConfig('last','尾页');
                        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                        $show = $page->show();
                        $list = $db->where(['look'=>8,'type'=>2,'ment'=>$apost,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
                        $title = '部门固定资产审批';


                        //---------------------------------------
                       
                        $lei = '行政';
                        $cao = 1;//行政操作分类
                        $this->assign('list',$list);
                        $this->assign('lei',$lei);
                        $this->assign('cao',$cao);
                       
                        $this->assign('page',$show);
                        
                        $this->assign('title',$title);
                    $this->display();
                  break;

                case '采购中心':
                    $db = M("look");
                    // echo '111';
                    // exit;
                        // $where = "a_id=".$uid;
                        $count = $db->where(['look'=>9,'type'=>2,'ment'=>$apost,'ju'=>0])->count();
                        // dump($count);
                        // exit;
                        $pagecount = 9;
                        $page = new \Think\Page($count , $pagecount);
                        // $row[] = '';
                        $page->parameter = $row; //此处的row是数组，为了传递查询条件
                        $page->setConfig('first');
                        $page->setConfig('prev','上一页');
                        $page->setConfig('next','下一页');
                        $page->setConfig('last','尾页');
                        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                        $show = $page->show();
                        $list = $db->where(['look'=>9,'type'=>2,'ment'=>$apost,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
                        $title = '部门固定资产审批';


                        //---------------------------------------
                       
                    
                        $this->assign('list',$list);
                       
                        $this->assign('page',$show);
                        
                        $this->assign('title',$title);
                        $this->display();
                  break;
                case '财务中心':
                    $db = M("look");
                    
                        $count = $db->where(['look'=>10,'type'=>2,'ment'=>$apost,'ju'=>0])->count();
                        // dump($count);
                        // exit;
                        $pagecount = 9;
                        $page = new \Think\Page($count , $pagecount);
                        $page->parameter = $row; //此处的row是数组，为了传递查询条件
                        $page->setConfig('first');
                        $page->setConfig('prev','上一页');
                        $page->setConfig('next','下一页');
                        $page->setConfig('last','尾页');
                        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                        $show = $page->show();
                        $list = $db->where(['look'=>10,'type'=>2,'ment'=>$apost,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
                        $title = '部门固定资产审批';


                        //---------------------------------------
                       
                        $lei = '财务';
                        $this->assign('list',$list);
                        $this->assign('lei',$lei);
                       
                        $this->assign('page',$show);
                        
                        $this->assign('title',$title);
                        $this->display();
                  break;
                
                
              }





              
            break;
          case '4':  //行政
              $db = M("look");
                  // $where = "a_id=".$uid;
                  $count = $db->where(array('type'=>2,'look'=>2,'ju'=>0))->count();
                  $pagecount = 9;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first'); 
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->where(array('type'=>2,'look'=>2,'ju'=>0))->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  $title = '公司固定资产审批';
            //       $Model = M('look');//或者 $Model = D(); 或者 $Model = M();
              // $sql = "SELECT * FROM oa_look WHERE `num` > `number` AND `type` = 3 AND `look` = 2 AND `ju` = 0 ";
              // $voList = $Model->query($sql);
              // dump($list);
              // exit;
                  // $ylist = $db->where(array('type'=>1,'look'=>2,'ju'=>0))->select();
                  // foreach ($ylist as  $v) {
                  //   $coun += $v['zong']; 
                  // }
                  // $title = '无库存月度需求申请';
            

              
                  $lei = '4';
                  $dao = 3;
                  $zong = 1;
              

                  $cao = 1;//行政操作分类
                  $this->assign('cao',$cao);
                  $this->assign('zong',$zong);
                  $this->assign('list',$list);
                  $this->assign('coun',$coun);
                  $this->assign('dao',$dao);
                  $this->assign('lei',$lei);
                  $this->assign('page',$show);
                  $this->assign('title',$title);
              $this->display();
            break;

        

          case '5':  //财务
              $db = M("look");
                  // $where = "a_id=".$uid;
                  $count = $db->where(array('type'=>2,'look'=>3,'ju'=>0))->count();
                  $pagecount = 10;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->where(array('type'=>2,'look'=>3,'ju'=>0))->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  $title = '公司固定资产审批';
                  $lei = 1;
                  $ylist = $db->where(array('type'=>2,'look'=>3,'ju'=>0))->select();
                  // foreach ($ylist as  $v) {
                  //   $coun += $v['zong']; 
                  // }
                  // $this->assign('coun',$coun);
                  $zong = 1;
                  $this->assign('zong',$zong);
                  $this->assign('list',$list);
                  $this->assign('lei',$lei);
                  $this->assign('page',$show);
                  $this->assign('title',$title);
              $this->display();
            break;



          case '9':  //职能总经理
              $db = M("look");
              $mlist = M('auth_group')->where(['mtype'=>2])->select();

              foreach ($mlist as $vn) {
            
                $ments[] =  $vn['title'];
              

              }
               $where = [
                      'ment' => [
                          'in',
                          $ments
                      ],
                      'look' => 1,
                      'type'=>2,
                      'ju'   => 0

                  ];

                
                  $count = $db->where($where)->count();
                  
                  $pagecount = 10;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->where($where)->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  $title = '部门固定资产审批';
                  $lei = '总经理';
                  // $ylist = $db->where(array('type'=>1,'look'=>1,'ju'=>0))->select();
                  // foreach ($ylist as  $v) {
                  //   $coun += $v['zong']; 
                  // }
                  $this->assign('coun',$coun);
                  $this->assign('list',$list);
                  $this->assign('lei',$lei);
                  $this->assign('page',$show);
                  $this->assign('title',$title);
                  $this->display();
            break;




          case '8':  //网络中心总经理
              $db = M("look");
              $mlist = M('auth_group')->where(['mtype'=>1])->select();

              foreach ($mlist as $vn) {
              // echo $v['n_id'];
              // exit;
              // $ment .= "`ment`="."'".$vn['title']."'"." or ";
              // $ment .= "'".$vn['title']."'"." , ";
                $ments[] =  $vn['title'];
                // 

              }
               $where = [
                      'ment' => [
                          'in',
                          $ments
                      ],
                      'look' => 1,
                      'type'=>2,
                      'ju'   => 0

                  ];

                  // dump($where);
                  // exit;
                  // $where = "a_id=".$uid;
                  $count = $db->where($where)->count();
                  // dump($count);
                  // exit;
                  $pagecount = 10;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->where($where)->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  $title = '部门固定资产审批';
                  // $lei = 1;
                  // $alist = M('look')->order('ment desc')->select();
                  // dump($alist);
                  // exit;
                  // $b = 0;
                  // foreach ($list as  $v) {
                  //  $b += $v['']
                  // }
                  // field()
                  $this->assign('list',$list);
                  // $this->assign('lei',$lei);
                  $this->assign('page',$show);
                  $this->assign('title',$title);
              $this->display();
            break;


          case '6':  //董事办
                  $db = M("look");
                  // $where = "a_id=".$uid;
                  $count = $db->where(['type'=>2,'look'=>5,'ju'=>0])->count();
                  $pagecount = 10;
                 
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->where(['type'=>2,'look'=>5,'ju'=>0])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  $title = '公司固定资产审批';
                  $lei = 1;
                  // $alist = M('look')->order('ment desc')->select();
                  // dump($list);
                  // exit;
                  // $b = 0;
                  // foreach ($list as  $v) {
                  //  $b += $v['']
                  // }
                  // field()
                 
                  // $this->assign('coun',$coun);
                  $zong = 1;
                  $this->assign('zong',$zong);
                  $this->assign('list',$list);
                  $this->assign('lei',$lei);
                  $this->assign('page',$show);
                  $this->assign('title',$title);
              $this->display();
            break;

          }
    }




 //公司所有固定资产审批模版页面
  public function jsuo()
  {
    $gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
    // dump($gid);
    // exit;
    $glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
    // dump($glist);
    // exit;
    $ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
    $apost = $glist[0]['post'];
    // dump($_GET);
          switch ($ulist[0]['m_type']) {
            case '3':   //经理
                switch ($apost) {
                  case '行政中心':
                        $db = M("look");
                        // echo '111';
                        // exit;
                        // $where = "a_id=".$uid;
                        $count = $db->where(['look'=>2,'type'=>2,'ju'=>0])->count();
                        // dump($count);
                        // exit;
                        $pagecount = 20;
                        $page = new \Think\Page($count , $pagecount);
                        // $row[] = '';
                        $page->parameter = $row; //此处的row是数组，为了传递查询条件
                        $page->setConfig('first');
                        $page->setConfig('prev','上一页');
                        $page->setConfig('next','下一页');
                        $page->setConfig('last','尾页');
                        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                        $show = $page->show();
                        $list = $db->where(['look'=>2,'type'=>2,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
                        $title = '公司所有固定资产审批';

                        // dump($list);
                        // exit;
                        //---------------------------------------
                       
                        $lei = '行政';
                        $cao = 1;//行政操作分类
                        $this->assign('list',$list);
                        $this->assign('lei',$lei);
                        $this->assign('cao',$cao);
                       
                        $this->assign('page',$show);
                        
                        $this->assign('title',$title);
                    $this->display();
                  break;

                
                case '财务中心':
                        $db = M("look");
                    
                        $count = $db->where(['look'=>3,'type'=>2,'ju'=>0])->count();
                        // dump($count);
                        // exit;
                        $pagecount = 20;
                        $page = new \Think\Page($count , $pagecount);
                        $page->parameter = $row; //此处的row是数组，为了传递查询条件
                        $page->setConfig('first');
                        $page->setConfig('prev','上一页');
                        $page->setConfig('next','下一页');
                        $page->setConfig('last','尾页');
                        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                        $show = $page->show();
                        $list = $db->where(['look'=>3,'type'=>2,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
                        $title = '公司所有固定资产审批';


                        //---------------------------------------
                       
                        $lei = '财务';
                        $this->assign('list',$list);
                        $this->assign('lei',$lei);
                       
                        $this->assign('page',$show);
                        
                        $this->assign('title',$title);
                        $this->display();
                  break;
                
                
              }





              
            break;
          case '9':  //职能总经理
              $db = M("look");
                    
              $count = $db->where(['look'=>4,'type'=>2,'ju'=>0])->count();
              // dump($count);
              // exit;
              $pagecount = 9;
              $page = new \Think\Page($count , $pagecount);
              $page->parameter = $row; //此处的row是数组，为了传递查询条件
              $page->setConfig('first');
              $page->setConfig('prev','上一页');
              $page->setConfig('next','下一页');
              $page->setConfig('last','尾页');
              $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
              $show = $page->show();
              $list = $db->where(['look'=>4,'type'=>2,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
              $title = '公司所有固定资产审批';


              //---------------------------------------
                       
              $lei = '总经理';
              $this->assign('list',$list);
              $this->assign('lei',$lei);
                       
              $this->assign('page',$show);
                        
              $this->assign('title',$title);
              $this->display();
            break;
          }
 
    
  }


 public function xiu()
  {

    $id = $_POST['id'];
    $data = $_POST;
    // $data['zong'] = $_POST['num'] * $_POST['unit'];
    $ce = M('look')->where(['id'=>$id])->find();
    // dump($data);
    // exit;
    if ($_POST['unit'] == $ce['unit'] && $_POST['num'] == $ce['num']) {
      echo '3';
      exit;
      // exit;
    }
    

    if (M('look')->where(['id'=>$id])->save($data) > 0) {
    
      
        // $coun['dan'] = $data['zong'];
      // $this->ajaxReturn($coun);
      echo '1111';
    }else{
      $arr = 2;
      $this->ajaxReturn($arr);
    }
  }







    //查看所有通过
    public function gsuo()
    {
        $ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
        $uname = $ulist[0]['user'];
        $alist = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
        $glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
        if ($ulist[0]['m_type'] >= 3) {
            $db = M("look");
            // $where = "a_id=".$uid;
            $count = $db->where(['look'=>6,'ju'=>0,'que'=>0])->count();
            $pagecount = 15;
            $page = new \Think\Page($count , $pagecount);
                          // $row[] = '';
            $page->parameter = $row; //此处的row是数组，为了传递查询条件
            $page->setConfig('first','第一页');
            $page->setConfig('prev','上一页');
            $page->setConfig('next','下一页');
            $page->setConfig('last','尾页');
            $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
            $show = $page->show();
            $list = $db->where(['look'=>6,'ju'=>0,'que'=>0])->order('time desc')->limit($page->firstRow.','.$page->listRows)->select();
            $title = '已通过固定资产审批';
            if ($glist[0]['post'] == '行政中心') {
                $lei = '行政';
                $this->assign('lei',$lei);
            }
            $this->assign('list',$list);
            // $this->assign('coun',$coun);
            // $this->assign('dao',$dao);
            // $this->assign('lei',$lei);
            $this->assign('page',$show);
            $this->assign('title',$title);
            $this->display();
        }else{
            $db = M("look");
            // $where = "a_id=".$uid;
            $count = $db->where(['look'=>6,'ju'=>0,'uname'=>$uname,'que'=>0])->count();
            $pagecount = 15;
            $page = new \Think\Page($count , $pagecount);
                          // $row[] = '';
            $page->parameter = $row; //此处的row是数组，为了传递查询条件
            $page->setConfig('first','第一页');
            $page->setConfig('prev','上一页');
            $page->setConfig('next','下一页');
            $page->setConfig('last','尾页');
            $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
            $show = $page->show();
            $list = $db->where(['look'=>6,'ju'=>0,'uname'=>$uname,'que'=>0])->order('time desc')->limit($page->firstRow.','.$page->listRows)->select();
            $title = '已通过固定资产审批';
            $this->assign('list',$list);
            // $this->assign('coun',$coun);
            // $this->assign('dao',$dao);
            // $this->assign('lei',$lei);
            $this->assign('page',$show);
            $this->assign('title',$title);
            $this->display();
        }
       

    }






    //查看所有拒绝
    public function gjue()
    {
        $ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
        $uname = $ulist[0]['user'];
        $alist = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
        $glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
        if ($ulist[0]['m_type'] >= 3) {
            switch ($ulist[0]['m_type']) {
                case '3':   //经理
                  $db = M("look");
                  // $apost = $glist[0]['post'];
                  // $x_list = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->order('id DESC')->select();
                  $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->count();
                  // dump($count);
                  // exit;
                  $pagecount = 15;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  // $xnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->count();
                  // $gnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>2])->count();
                  // $jnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>1])->count();
                  // $y_list = M('cost')->where(['look'=>0,'ment'=>$apost,'ju'=>0,])->order('id DESC')->limit(5)->select();
                   $title = '已被拒绝固定资产审批';
                  $this->assign('list',$list);
                  $this->assign('title',$title);
                  $this->assign('page',$show);
                  // $this->assign('xnum',$xnum);
                  // $this->assign('gnum',$gnum);
                  // $this->assign('jnum',$jnum);
                  // $this->assign('y_list',$y_list);
                  $this->display();
                  break;
                case '4':   //行政
                  $db = M("look");
                  // $apost = $glist[0]['post'];
                  // $x_list = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->order('id DESC')->select();
                  $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->count();
                  // dump($count);
                  // exit;
                  $pagecount = 15;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  // $xnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->count();
                  // $gnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>2])->count();
                  // $jnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>1])->count();
                  // $y_list = M('cost')->where(['look'=>0,'ment'=>$apost,'ju'=>0,])->order('id DESC')->limit(5)->select();
                   $title = '已被拒绝固定资产审批';
                  $this->assign('list',$list);
                  $this->assign('title',$title);
                  $this->assign('page',$show);
                  // $this->assign('xnum',$xnum);
                  // $this->assign('gnum',$gnum);
                  // $this->assign('jnum',$jnum);
                  // $this->assign('y_list',$y_list);
                  $this->display();
                  break;
                case '5':   //财务
                  $db = M("look");
                  // $apost = $glist[0]['post'];
                  // $x_list = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->order('id DESC')->select();
                  $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[5,6]],'oa_look.type'=>2])->count();
                  // dump($count);
                  // exit;
                  $pagecount = 15;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[5,6]],'oa_look.type'=>2])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                  // $xnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->count();
                  // $gnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>2])->count();
                  // $jnum = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>1])->count();
                  // $y_list = M('cost')->where(['look'=>0,'ment'=>$apost,'ju'=>0,])->order('id DESC')->limit(5)->select();
                  $this->assign('list',$list);
                  $this->assign('page',$show);
                   $title = '已被拒绝固定资产审批';
                  $this->assign('title',$title);
                  // $this->assign('xnum',$xnum);
                  // $this->assign('gnum',$gnum);
                  // $this->assign('jnum',$jnum);
                  // $this->assign('y_list',$y_list);
                  $this->display();
                  break;
                case '6':   //董事办
                  $db = M("look");
                  // $apost = $glist[0]['post'];
                  // $x_list = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->order('id DESC')->select();
                  $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_cost.ju'=>'6','oa_look.type'=>2])->count();
                  // dump($count);
                  // exit;
                  $pagecount = 15;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_cost.ju'=>'6','oa_look.type'=>2])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                 
                  $this->assign('list',$list);
                  $this->assign('page',$show);
                    $title = '已被拒绝固定资产审批';
                  $this->assign('title',$title);
               
                  $this->display();
                  break;
                case '9':   //总经理
                  $db = M("look");
                  // $apost = $glist[0]['post'];
                  // $x_list = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->order('id DESC')->select();
                  $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->count();
                  // dump($count);
                  // exit;
                  $pagecount = 15;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                   $title = '已被拒绝固定资产审批';
                  $this->assign('title',$title);
                  $this->assign('list',$list);
                  $this->assign('page',$show);
                  
                  $this->display();
                  break;
                case '8':   //总经理
                  $db = M("look");
                  // $apost = $glist[0]['post'];
                  // $x_list = M('look')->where(['look'=>0,'ment'=>$apost,'ju'=>0,'type'=>0])->order('id DESC')->select();
                  $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->count();
                  // dump($count);
                  // exit;
                  $pagecount = 15;
                  $page = new \Think\Page($count , $pagecount);
                  // $row[] = '';
                  $page->parameter = $row; //此处的row是数组，为了传递查询条件
                  $page->setConfig('first');
                  $page->setConfig('prev','上一页');
                  $page->setConfig('next','下一页');
                  $page->setConfig('last','尾页');
                  $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
                  $show = $page->show();
                  $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['in',[3,4,5,6]],'oa_look.type'=>2])->order('ment desc')->limit($page->firstRow.','.$page->listRows)->select();
                   $title = '已被拒绝固定资产审批';
                  $this->assign('title',$title);
                  $this->assign('list',$list);
                  $this->assign('page',$show);
                  
                  $this->display();
                  break;
            }
        }else{
            $db = M("look");
            
            $count = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['neq',0],'oa_look.uname'=>$uname,'oa_look.type'=>2])->count();
            // dump($count);
            // exit;
            $pagecount = 15;
            $page = new \Think\Page($count , $pagecount);

                          // $row[] = '';
            $page->parameter = $row; //此处的row是数组，为了传递查询条件
            $page->setConfig('first','第一页');
            $page->setConfig('prev','上一页');
            $page->setConfig('next','下一页');
            $page->setConfig('last','尾页');
            $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
            $show = $page->show();

            $list = $db->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.ju'=>['neq',0],'oa_look.uname'=>$uname,'oa_look.type'=>2])->order('time desc')->limit($page->firstRow.','.$page->listRows)->select();

            // dump($list);
            // exit;
            $title = '已被拒绝固定资产审批';
            $this->assign('title',$title);
            $this->assign('list',$list);
            // $this->assign('coun',$coun);
            // $this->assign('dao',$dao);
            // $this->assign('lei',$lei);
            $this->assign('page',$show);
            $this->assign('title',$title);
            $this->display();
        }
       

    }




    //确定用户领用
    public function que()
    {
      
      $llist = M('look')->where(['id'=>$_POST['id']])->find();
      
      $que['que'] = '1';
      $que['number'] = $llist['number'] - $llist['num'];
      $number['number'] = $llist['number'] - $llist['num'];
      // dump($que);
      // exit;
      if (M('look')->where(['id'=>$_POST['id']])->save($que) > 0 ) {
          echo '1111';
      }else{
          echo '2222';
      }


    }










    public function addo()
    {
      if (IS_POST) {
          $dada = M('member')->where(array('uid'=>$_SESSION['uid']))->select();
          $z_id = M('auth_group_access')->where(array('uid'=>$_SESSION['uid']))->select();
                  
          $b_id = $z_id[0]['group_id'];
          $m_list = M('auth_group')->where(array('id'=>$b_id))->select();
          $slist = M('stock')->where(['id'=>$_POST['id']])->select();
          $list = $_POST;
          foreach ($list as $k => $v ){
             foreach ($v as $key => $value){
                 if (!$value){
                     unset($list[$k][$key]);
                     continue;
                 }
             }
             // if(empty($v)){
             //     unset($list[$k]);
             // }
            }
          $result = array_filter($list);
            
          $result = array_values($result); 
          // dump($result);
          // exit;
          M()->startTrans();
          foreach ($result as $value) {
              if (!M('gu')->add($value)) {
                  M()->rollback();
                  return $this->error('添加失败');
              }
          }
          M()->commit();
          return $this->success('添加成功');


      }else{
        $this->display();
      }
    }





    //删除单条信息
    public function del()
    {
      // dump(I());
      switch ($_POST['type']) {
        case '1':     
          if (M('gu')->where(['id'=>$_POST['id']])->delete() > 0) {
              echo '1111';
          }else{
              echo '2222';
          }
          break;
        case '2':     
          // dump(I());
          // exit;
          if (M('gxiu')->where(['id'=>$_POST['id']])->delete() > 0) {
              echo '1111';
          }else{
              echo '2222';
          }
          break;
       
      }
      
    }



    //固定资产修改界面
    public function gxiu()
    {
      $glist = M('gu')->where(['id'=>$_GET['id']])->select();
      // dump($glist);
      // exit;
      $gxiu = M('gxiu')->where(['gid'=>$_GET['id']])->order('id desc')->limit(10)->select();
      $this->assign('glist',$glist);
      $this->assign('gxiu',$gxiu);
      $this->display();
    }



    //固定资产修改操作
    public function gxiuo()
    { 
      // dump(I());
      // exit;
      $id = $_POST['id'];
      $glist = M('gu')->where(['id'=>$id])->find();
      $dada = M('member')->where(array('uid'=>$_SESSION['uid']))->select();
      $glist['gid'] = $_POST['id'];
      $glist['time'] = date('Y-m-d');
      $list = $_POST;
      $glist['xname'] = $dada[0]['user'];
      // dump($glist);
      // exit;
      unset($list['id']);
      unset($glist['id']);
      if (M('gu')->where(['id'=>$id])->save($list) > 0) {
          if (M('gxiu')->add($glist) > 0) {
            echo '1111';
          }
      }else{
        echo '2222';
      }
      


    }





    public function xiang()
    {
      
      $list = M('look')->join('oa_sh as t1 on t1.sid = oa_look.id')->where(['oa_look.id'=>$_GET['id']])->select();
      // dump($list);
      // exit;
      
      $this->assign('list',$list);
      $this->display();
    }






}